Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google oauth handler using an external Python script #345

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gaganpreet
Copy link
Contributor

This fixes Google authorization by relying on an external Python script to handle redirects. I tested a couple of scenarios and it works fine on my end. I stuck to the standard library so it should work on every system out of the box.

Fixes #333

@MRo47
Copy link

MRo47 commented Apr 17, 2023

Tested this on

Kubuntu 22.04
5.19.0-38-generic

No issues while sigining up, loads all events.

Thank you

@Zren
Copy link
Owner

Zren commented Apr 19, 2023

I prefer this solution to the golang one. I assume the golang binary would run in any distro but I wouldn't be able to confirm that.

I was apprehensive of depending on the executable dataengine for both of these PRs as I wasn't sure if all dataengines were being removed in Plasma6 though. Seems that there's going to be a Plasma5Support package to keep them around for the short term though.

I'd originally planned to rewrite all of the the google api request code in python, but the golang PR made me realize that was overkill. Thank you both for the simpler solution.

Copy link
Owner

@Zren Zren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can comment/fix these after merging. Still need to test this code before merging it.

package/contents/ui/config/GoogleLoginManager.qml Outdated Show resolved Hide resolved
b"OAuth redirect handled successfully. You can close this tab now."
)
raise SystemExit(0)
self.wfile.write(b"Missing code parameter in redirect.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the path of this file? Or is it stdout? or stderr? Is there a reason for using write instead of print() (no newline)?

https://docs.python.org/3/library/http.server.html#http.server.BaseHTTPRequestHandler.wfile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.wfile is to write the response back to the client, in this case the browser (to guide the user what to do). For example, after a successful redirect, the user will see this in their browser:

Screenshot_20230419_232904

The print output is for communication with the QML script (using the executable.exec helper).

@dodo-the-dev
Copy link

I've cloned this repo and installed it, but when trying to sign in to google, I keep getting the issue as previous. How do we use the python script to log in?

@shakeelansari63
Copy link

Installed this version and can confirm it works like a charm.
I am on Endeavor OS (Arch), KDE 5.27.4

@shakeelansari63
Copy link

I've cloned this repo and installed it, but when trying to sign in to google, I keep getting the issue as previous. How do we use the python script to log in?

Did you switch to google-calendar-fix branch?
I did same mistake, I cloned gaganpreet's repo and installed it from master branch not realising the changes are in different branch. And was still getting same error.
But later switched to google-calendar-fix branch and re-installed and it started working.

@dodo-the-dev
Copy link

I've cloned this repo and installed it, but when trying to sign in to google, I keep getting the issue as previous. How do we use the python script to log in?

Did you switch to google-calendar-fix branch? I did same mistake, I cloned gaganpreet's repo and installed it from master branch not realising the changes are in different branch. And was still getting same error. But later switched to google-calendar-fix branch and re-installed and it started working.

Well, do I fell dumb or what 🤣

@dodo-the-dev
Copy link

Ok, I tried that, and still doesn't work. Just keeps coming up with the same error. What am I not doing correctly?

@shakeelansari63
Copy link

Try Clean Install.

Remove Old plasmoid

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar

And then install updated one.

@dodo-the-dev
Copy link

Try Clean Install.

Remove Old plasmoid

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar

And then install updated one.

Nope, used that, still get the same. I give up!

Thanks for your help thought

@shakeelansari63
Copy link

@dodo-the-dev
Just wondering how did you install it originally. Did you install it from KDE store / Git or via your Distro's Package manager.

If you had installed via distro's package manager, it might be installed system wide in /usr/share/plasma/plasmoids/

In that case, you may have to remove it from /usr/share/plasma/plasmoids/ for clean install.

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar

And then install it from gaganpreet:google-calendar-fix

You can give this a try if you wish to 👍

@dodo-the-dev
Copy link

Oh wow, I didn't have anything in those folders, so I downloaded the Zip instead of the github and it worked first time. Not sure why, but thanks

@aokugel
Copy link

aokugel commented May 22, 2023

Works for me on fedora 38, Plasma 5.27.5

@pmsobrado
Copy link

pmsobrado commented May 22, 2023

@gaganpreet Could you make this changes also for v68 branch? I tried to add them manually to that branch but then I got error 401 invalid client or client not found. I need v68 branch because of this:

#153

@kanocz
Copy link

kanocz commented Jun 7, 2023

@Zren and when this pull request will be merged? :)

@NeilPandya
Copy link

NeilPandya commented Jun 9, 2023

Hi @Zren, just wanted to let you know that I tested @gaganpreet's solution via python script and it works on my system!

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar

git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

System Specs:

           `.:/ossyyyysso/:.               neil@FractalNorth 
        .:oyyyyyyyyyyyyyyyyyyo:`           ----------------- 
      -oyyyyyyyodMMyyyyyyyysyyyyo-         OS: Kubuntu 22.04.2 LTS x86_64 
    -syyyyyyyyyydMMyoyyyydmMMyyyyys-       Kernel: 5.19.0-43-generic 
   oyyysdMysyyyydMMMMMMMMMMMMMyyyyyyyo     Uptime: 1 hour, 30 mins 
 `oyyyydMMMMysyysoooooodMMMMyyyyyyyyyo`    Packages: 2490 (dpkg), 19 (flatpak), 9 (snap) 
 oyyyyyydMMMMyyyyyyyyyyyysdMMysssssyyyo    Shell: bash 5.1.16 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Resolution: 1920x1080 
oyyyysoodMyyyyyyyyyyyyyyyyyyydMMMMysyyyo   DE: Plasma 5.24.7 
yyysdMMMMMyyyyyyyyyyyyyyyyyyysosyyyyyyyy   WM: KWin 
yyysdMMMMMyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy   WM Theme: Sweet-Dark-transparent 
oyyyyysosdyyyyyyyyyyyyyyyyyyydMMMMysyyyo   Theme: [Plasma], Breeze [GTK2/3] 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Icons: candy-icons [Plasma], candy-icons [GTK2/3] 
 oyyyyyydMMMysyyyyyyyyyyysdMMyoyyyoyyyo    Terminal: konsole 
 `oyyyydMMMysyyyoooooodMMMMyoyyyyyyyyo     CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz 
   oyyysyyoyyyysdMMMMMMMMMMMyyyyyyyyo      GPU: NVIDIA GeForce RTX 3090 
    -syyyyyyyyydMMMysyyydMMMysyyyys-       Memory: 4283MiB / 32008MiB 
      -oyyyyyyydMMyyyyyyysosyyyyo-
        ./oyyyyyyyyyyyyyyyyyyo/.                                   
           `.:/oosyyyysso/:.`

@elbecerrasoto
Copy link

elbecerrasoto commented Jul 31, 2023

I followed as @NeilPandya, works in my system too.

ebecerra@muss 
------------- 
OS: Manjaro Linux x86_64 
Host: Latitude 5430 
Kernel: 6.1.41-1-MANJARO 
Uptime: 23 mins 
Packages: 1316 (pacman), 9 (flatpak) 
Shell: zsh 5.9 
Resolution: 1920x1080 
DE: Plasma 5.27.6 
WM: kwin 
Theme: [Plasma], Breeze [GTK2/3] 
Icons: [Plasma], breeze [GTK2/3] 
Terminal: konsole 
Terminal Font: IBM Plex Mono 18 
CPU: 12th Gen Intel i7-1265U (12) @ 4.800GHz 
GPU: Intel Alder Lake-UP3 GT2 [Iris Xe Graphics] 
Memory: 4039MiB / 31787MiB 

@dhupee
Copy link

dhupee commented Sep 6, 2023

hey @Zren, its been a month since last reference of this PR and Im wondering when will you merge this PR or whether you need more test from others on which side?

EDIT:

I manage to use this branch and It's working, took me a bit of a brawl since I use @kanocz version first and i need to do clean install thx to @NeilPandya

                     ./o.                  dhupee@Akago 
                   ./sssso-                ¨¨¨¨¨¨¨¨¨¨¨¨ 
                 `:osssssss+-              ╭──────────── Software ──────────── 
               `:+sssssssssso/.            │ OS› EndeavourOS 
             `-/ossssssssssssso/.          │ Kernel› 6.4.12-arch1-1 
           `-/+sssssssssssssssso+:`        │ Packages› 1367 (pacman), 12 (flatpak) 
         `-:/+sssssssssssssssssso+/.       │ Shell› zsh 5.9 
       `.://osssssssssssssssssssso++-      │ DE› Plasma 5.27.7 
      .://+ssssssssssssssssssssssso++:     │ Terminal› konsole 
    .:///ossssssssssssssssssssssssso++:    │ Local IP› 172.16.0.2 
  `:////ssssssssssssssssssssssssssso+++.   ├──────────── Hardware ──────────── 
`-////+ssssssssssssssssssssssssssso++++-   │ Host› Nitro AN515-43 V1.12 
 `..-+oosssssssssssssssssssssssso+++++/`   │ CPU› AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx (8) @ 2.100GHz 
   ./++++++++++++++++++++++++++++++/:.     │ GPU› AMD ATI Radeon Vega Series / Radeon Vega Mobile Series 
  `:::::::::::::::::::::::::------``       │ GPU› AMD ATI Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X 
                                           │ Memory› 8069MiB / 13916MiB 
                                           │ Disk (/)› 171G / 901G (20%) 
                                           ├───────────── Uptime ───────────── 
                                           │› 5 days, 18 hours, 50 mins 

@magdymawad
Copy link

Thanks to @gaganpreet, @NeilPandya for his guide.
It works perfectly on

Operating System: openSUSE Tumbleweed 20230906
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10
Kernel Version: 6.4.12-1-default (64-bit)
Graphics Platform: X11

@Pentasis
Copy link

Pentasis commented Oct 2, 2023

Works on:
Operating System: Manjaro Linux
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.3-1-MANJARO (64-bit)

But I do get a warning: "Providing a metadata.desktop file for KPackage metadata is deprecated." Which is just minor and it installs perfectly and Authorisation works.

@NeilPandya
Copy link

@Zren any update to when this branch can be merged?

@joaociocca
Copy link

Hi @Zren, just wanted to let you know that I tested @gaganpreet's solution via python script and it works on my system!

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar

git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

works nicely here too!

                  -`                    johnny@johnny-g55590
                 .o+`                   --------------------
                `ooo/                   OS: Garuda Linux x86_64
               `+oooo:                  Host: G5 5590 
              `+oooooo:                 Kernel: 6.6.4-zen1-1-zen
              -+oooooo+:                Uptime: 1 hour, 10 mins
            `/:-:++oooo+:               Battery: 100% [Full]
           `/++++/+++++++:              
          `/++++++++++++++:             Packages: 1907 (pacman)
         `/+++ooooooooooooo/`           Shell: zsh
        ./ooosssso++osssssso+`          Resolution: 2560x2160
       .oossssso-````/ossssss+`         Terminal: kitty
      -osssssso.      :ssssssso.        
     :osssssss/        osssso+++.       CPU: Intel i7-9750H (12) @ 4.5GHz
    /ossssssss/        +ssssooo/-       Memory: 6119MiB / 15803MiB (38%)
  `/ossssso+/:-        -:/+osssso+-     
 `+sso+:-`                 `.-/+oso:                            
`++:.                           `-/+/                           
.`                                 `/   

@joaociocca joaociocca mentioned this pull request Dec 8, 2023
@BackOnMyBS
Copy link

I'm following these steps:

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar

git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

However, when I get to git switch google-calendar-fix , I get the following:
fatal: invalid reference: google-calendar-fix

Any ideas on what I'm doing wrong? I'm very layperson with this entire scene btw.

@joaociocca
Copy link

Any ideas on what I'm doing wrong? I'm very layperson with this entire scene btw.

not without knowing/seeing exactly what you tried. Command by command.

@shakeelansari63
Copy link

Wish this PR soon gets merged to master. So that people don't have to keep working with workarounds like cloning feature branch and installing manually.

@NeilPandya
Copy link

I'm following these steps:

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar
git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

However, when I get to git switch google-calendar-fix , I get the following: fatal: invalid reference: google-calendar-fix

Any ideas on what I'm doing wrong? I'm very layperson with this entire scene btw.

@BackOnMyBS ,

Can you type git branch, and share the results? We can see what branches are shown as available to be switched to in the repo you cloned.

Neil

@NeilPandya
Copy link

NeilPandya commented Jan 7, 2024

Any ideas on what I'm doing wrong? I'm very layperson with this entire scene btw.

not without knowing/seeing exactly what you tried. Command by command.

@BackOnMyBS Also, maybe you can try again and copy/paste your terminal output to another post here or on pastebin or something like that so others can take a look?

@shakeelansari63
Copy link

shakeelansari63 commented Jan 7, 2024

I'm following these steps:

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar
git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

However, when I get to git switch google-calendar-fix , I get the following: fatal: invalid reference: google-calendar-fix

Any ideas on what I'm doing wrong? I'm very layperson with this entire scene btw.

Try git checkout google-calendar-fix instead of git switch google-calendar-fix if that helps

@NeilPandya
Copy link

@Zren Any updates on when this PR can be merged? Thanks again.

@roosartwork
Copy link

Hi @Zren, just wanted to let you know that I tested @gaganpreet's solution via python script and it works on my system!

rm -rf ~/.local/share/plasma/plasmoids/org.kde.plasma.eventcalendar
sudo rm -rf /usr/share/plasma/plasmoids/org.kde.plasma.eventcalendar

git clone https://github.com/gaganpreet/plasma-applet-eventcalendar eventcalendar
cd eventcalendar
git switch google-calendar-fix
git pull
sh ./install

System Specs:

           `.:/ossyyyysso/:.               neil@FractalNorth 
        .:oyyyyyyyyyyyyyyyyyyo:`           ----------------- 
      -oyyyyyyyodMMyyyyyyyysyyyyo-         OS: Kubuntu 22.04.2 LTS x86_64 
    -syyyyyyyyyydMMyoyyyydmMMyyyyys-       Kernel: 5.19.0-43-generic 
   oyyysdMysyyyydMMMMMMMMMMMMMyyyyyyyo     Uptime: 1 hour, 30 mins 
 `oyyyydMMMMysyysoooooodMMMMyyyyyyyyyo`    Packages: 2490 (dpkg), 19 (flatpak), 9 (snap) 
 oyyyyyydMMMMyyyyyyyyyyyysdMMysssssyyyo    Shell: bash 5.1.16 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Resolution: 1920x1080 
oyyyysoodMyyyyyyyyyyyyyyyyyyydMMMMysyyyo   DE: Plasma 5.24.7 
yyysdMMMMMyyyyyyyyyyyyyyyyyyysosyyyyyyyy   WM: KWin 
yyysdMMMMMyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy   WM Theme: Sweet-Dark-transparent 
oyyyyysosdyyyyyyyyyyyyyyyyyyydMMMMysyyyo   Theme: [Plasma], Breeze [GTK2/3] 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Icons: candy-icons [Plasma], candy-icons [GTK2/3] 
 oyyyyyydMMMysyyyyyyyyyyysdMMyoyyyoyyyo    Terminal: konsole 
 `oyyyydMMMysyyyoooooodMMMMyoyyyyyyyyo     CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz 
   oyyysyyoyyyysdMMMMMMMMMMMyyyyyyyyo      GPU: NVIDIA GeForce RTX 3090 
    -syyyyyyyyydMMMysyyydMMMysyyyys-       Memory: 4283MiB / 32008MiB 
      -oyyyyyyydMMyyyyyyysosyyyyo-
        ./oyyyyyyyyyyyyyyyyyyo/.                                   
           `.:/oosyyyysso/:.`

Operating System: Kubuntu 22.04 KDE Plasma Version: 5.24.7 KDE Frameworks Version: 5.92.0 Qt Version: 5.15.3 Kernel Version: 5.19.0-43-generic (64-bit) Graphics Platform: X11 Processors: 32 × AMD Ryzen 9 5950X 16-Core Processor Memory: 31.3 GiB of RAM Graphics Processor: NVIDIA GeForce RTX 3090/PCIe/SSE2

It works here too!!!

         _,met$$$$$gg.           dan@urios
      ,g$$$$$$$$$$$$$$$P.        OS: Debian 12 bookworm
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 6.1.0-21-amd64
   ,$$P'              `$$$.      Uptime: 10h 50m
  ',$$P       ,ggs.     `$$b:    Packages: 3249
  `d$$'     ,$P"'   .    $$$     Shell: bash 5.2.15
   $$P      d$'     ,    $$P     Resolution: 5760x1080
   $$:      $$.   -    ,d$$'     DE: KDE 5.103.0 / Plasma 5.27.5
   $$\;      Y$b._   _,d$P'      WM: KWin
   Y$$.    `.`"Y$$$$P"'          GTK Theme: Sweet-v40 [GTK2/3]
   `$$b      "-.__               Icon Theme: candy-icons
    `Y$$                         Disk: 2.9T / 5.7T (51%)
     `Y$$.                       CPU: Intel Core i5-9600K @ 6x 4.6GHz [50.0°C]
       `$$b.                     GPU: AMD Radeon RX 470 Graphics (polaris10, LLVM 15.0.6, DRM 3.49, 6.1.0-21-amd64)
         `Y$$b.                  RAM: 8752MiB / 15856MiB
            `"Y$b._             
                `""""           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug re:Google Calendar - Access blocked: KDE Event Calendar Widget’s request is invalid